<%@ page import="com.ld.businesscard_manage.service.BusinessCardService" %>
<%@ page import="com.ld.businesscard_manage.service.impl.BusinessCardServiceImpl" %>
<%@ page import="com.ld.businesscard_manage.bean.User" %>
<%@ page import="com.ld.businesscard_manage.bean.BusinessCard" %><%--
  Created by IntelliJ IDEA.
  User: 刘邓
  Date: 2023-06-10
  Time: 16:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改我的名片结果</title>
</head>
<body>
<%!
  private BusinessCardService cardService = new BusinessCardServiceImpl();
%>
<%
  User user = (User)(session.getAttribute("user"));
  request.setCharacterEncoding("utf-8");
  BusinessCard card0 = (BusinessCard) (session.getAttribute("currentCard"));
  Integer id = card0.getId();
  String name = card0.getName();
  Integer sex = card0.getSex();
  String account = card0.getAccount();
  String password = card0.getPassword();
  String email = card0.getEmail();
  Integer valid = card0.getValid();
  System.out.println(request.getParameter("email"));
  if (!request.getParameter("name").equals("")) {
    name = request.getParameter("name");
  }
  if(!request.getParameter("sex").equals("")){
    sex = Integer.parseInt(request.getParameter("sex"));
  }
  if(!request.getParameter("email").equals("")){
    email = request.getParameter("email");
  }
    BusinessCard card = new BusinessCard(id,name,sex,account,password,email,valid);
  System.out.println(card);
    int i = cardService.updateCard(card);
    if (i == 0) {
      out.println("<h1>修改失败,请稍后再试!</h1>");
    } else {
      out.println("<h1>修改成功</h1>");
  }
  out.println("<a href='/home/myCard.jsp'>返回个人名片管理页</a>");
%>
</body>
</html>
